package gui.dialogs;

import gui.components.MImage;

import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;

import utility.WindowManipulator;
import core.Configuration;

public class HelpDialog extends GameDialog implements ActionListener{
	
	private static int DIALOG_WIDTH = 740;
	private static int DIALOG_HEIGHT = 500;
	private static int LINE_HEIGHT = 30;
	JButton okBtn;
	Window parent;
	
	static{
		DIALOG_WIDTH = (int)(DIALOG_WIDTH*Configuration.zoomConst);
		DIALOG_HEIGHT = (int)(DIALOG_HEIGHT*Configuration.zoomConst);
	}
		
	public HelpDialog(Window parent){
		super(parent);
		this.setSize(DIALOG_WIDTH,DIALOG_HEIGHT);
		
		this.parent = parent;
		Container c = this.getContentPane();	
		
		
		MImage bkg = new MImage(Configuration.IMAGE_FOLDER_ILLUSTRATION+"gameBoardTransp.jpg");
		bkg.setBounds((int)(-(bkg.getSize().width-DIALOG_WIDTH)/2), (int)(-(bkg.getSize().height-DIALOG_HEIGHT)/2), bkg.getSize().width, bkg.getSize().height);
		
		
		JLabel title1 = new JLabel("HELP");
		title1.setForeground(new Color(228,42,42));
		title1.setFont(new Font("Sans Serif",Font.BOLD,18));
		title1.setBounds(0,10, DIALOG_WIDTH, 35);
		title1.setHorizontalAlignment(JLabel.CENTER);
		
		JButton closeButton = new JButton("Close");
						
		closeButton.addActionListener(new ActionListener() {
		
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
			    getInstance().getParentWindow().setEnabled(true);
				getInstance().dispose();				
			}
		});
		closeButton.setFont(new Font("Arial",Font.PLAIN,16));
		closeButton.setBounds((DIALOG_WIDTH-100)/2,DIALOG_HEIGHT-LINE_HEIGHT-20, closeButton.getPreferredSize().width, closeButton.getPreferredSize().height);

		
		JLabel finishImg = new JLabel();
		finishImg.setIcon(new ImageIcon("images/buy_button.png"));
		
		finishImg.setBounds(40, 60,finishImg.getPreferredSize().width , finishImg.getPreferredSize().height);
		
		JLabel dicesImg = new JLabel();
		dicesImg.setIcon(new ImageIcon("images/dices1.png"));
		dicesImg.setBounds(40, 60+20+ finishImg.getPreferredSize().height,dicesImg.getPreferredSize().width , dicesImg.getPreferredSize().height);
		
		JLabel buyImg = new JLabel();
		buyImg.setIcon(new ImageIcon("images/finish_turn.png"));
		buyImg.setBounds(40, 60+40+dicesImg.getPreferredSize().height+ finishImg.getPreferredSize().height,buyImg.getPreferredSize().width , buyImg.getPreferredSize().height);
		
		Font f = new Font("Arial",Font.PLAIN,16);
		
		JLabel finishLbl = new JLabel("Click this button, \n if you want to finish the turn.");
		finishLbl.setFont(f);
		finishLbl.setBounds(200, 60+finishImg.getPreferredSize().height/2,finishLbl.getPreferredSize().width , finishLbl.getPreferredSize().height);
		
		
		JLabel dicesLbl = new JLabel("Click this button, \n if you want to roll the dices.");
		dicesLbl.setFont(f);
		dicesLbl.setBounds(200, 60+20+ finishImg.getPreferredSize().height+dicesImg.getPreferredSize().height/2, dicesLbl.getPreferredSize().width , dicesLbl.getPreferredSize().height);
		
		
		JLabel buyLbl = new JLabel("Click this button, \n if you want to buy the street which you stand on.");
		buyLbl.setFont(f);
		buyLbl.setBounds(200, 60+40+dicesImg.getPreferredSize().height+ finishImg.getPreferredSize().height+finishImg.getPreferredSize().height/2, buyLbl.getPreferredSize().width , buyLbl.getPreferredSize().height);
		
		
		c.add(finishImg);
		c.add(dicesImg);
		c.add(buyImg);
		
		c.add(finishLbl);
		c.add(dicesLbl);
		c.add(buyLbl);

		c.add(title1);
		c.add(closeButton);
		c.add(bkg);

		WindowManipulator.movePositionToCenter(parent,this);
		this.setVisible(true);			
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		parent.setEnabled(true);
		this.dispose();
	}
}
